﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RentAWorker.Web.Factory;
using RentAWorker.Business.Interfaces;
using RentAWorker.Business.DTO;
using RentAWorker.WebNew.CustomerCode;

namespace RentAWorker.WebNew.Customer
{
    public partial class SearchResource : RentPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void SearchForWorkerCommand_Click(object sender, EventArgs e)
        {
            Dictionary<string, string> Parameters =
                new Dictionary<string, string>() 
                {
                    {SearchResultsHelper.SearchNameParameter, SearchNameText.Text}, 
                    {SearchResultsHelper.LocationParameter, SearchLocationText.SelectedValue}, 
                    {SearchResultsHelper.FromParameter, SearchFromDate.Text}, 
                    {SearchResultsHelper.ToParameter, SearchToDate.Text}, 
                };

            if (ResultsTabContainer.ActiveTab == WorkerTabPanel)
            {
                WorkerSearchResultsView.UpdateDataSource(Parameters);
            }
            else if (ResultsTabContainer.ActiveTab == MachineTabPanel)
            {
                Parameters.Add(SearchResultsHelper.MachineStatusParameter, MachineStatusText.Text);
                Parameters.Add(SearchResultsHelper.MachineTypeParameter, MachineTypeCombo.SelectedValue);

                MachineSearchResultsView.UpdateDataSource(Parameters);
            }
        }
    }
}
